﻿//接口隔离原则
namespace cs_basic_20 {
    class Program {
        static void Main(string[] args) {
            var driver = new Driver(new HeavyTank());
            driver.Drive();
        }
    }

    class Driver {
        private IVehicle _vehicle;

        public Driver(IVehicle vehicle) {
            _vehicle = vehicle;
        }

        public void Drive() {
            _vehicle.Run();
        }
    }

    interface IVehicle {
        void Run();
    }
    class Car: IVehicle {
        public void Run() {
            Console.WriteLine("Car running ...");
        }
    }
    class Truck: IVehicle {
        public void Run() {
            Console.WriteLine("Trunk running ...");
        }
    }

    interface IWeapen { 
        void Fire();
    } 
    
    interface ITank:IWeapen,IVehicle{

    }

    class LightTank : ITank {
        public void Fire() {
            Console.WriteLine("Boom!");
        }

        public void Run() {
            Console.WriteLine("Ka Ka Ka ...");
        }
    }
    class MiediumTank : ITank {
        public void Fire() {
            Console.WriteLine("Boom!");
        }

        public void Run() {
            Console.WriteLine("Ka! Ka! Ka! ...");
        }
    }
    class HeavyTank : ITank {
        public void Fire() {
            Console.WriteLine("Boom!");
        }

        public void Run() {
            Console.WriteLine("Ka!! Ka!! Ka!! ...");
        }
    }
}